package jsyf.oa.web.system;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.system.LogsFacade;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(value = "数据库字段日志", description = "数据库字段日志")
@Controller
@RequestMapping("/logs")
public class LogsController {

    @Resource
    private LogsFacade logsFacade;

    @RequestMapping(value = "/getColumnLogs.json", method = RequestMethod.POST)
    public void getColumnLogs(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObject = logsFacade.getColumnLogs(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrTimeRespond(jsonObject));
    }

    @RequestMapping(value = "/getTableLogs.json", method = RequestMethod.POST)
    public void getTableLogs(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObject = logsFacade.getTableLogs(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrTimeRespond(jsonObject));
    }

    @RequestMapping(value = "/getTableLogsNum.json", method = RequestMethod.POST)
    public void getTableLogsNum(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonObject = logsFacade.getTableLogsNum(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(jsonObject));
    }

    @RequestMapping(value = "/getColumnLogsNum.json", method = RequestMethod.POST)
    public void getColumnLogsNum(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonObject = logsFacade.getColumnLogsNum(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(jsonObject));
    }
}
